package com.tan.exception;

import com.tan.entity.ResultInfo;
import com.tan.utils.LogUtils;
import com.tan.utils.ResultUtils;
import org.springframework.web.bind.annotation.ControllerAdvice;
import org.springframework.web.bind.annotation.ExceptionHandler;
import org.springframework.web.bind.annotation.ResponseBody;

/**
 * @Author 谭永超 [www.tanyongchao.tk:8090/SumDome/index]
 * @Date 2018/8/21 16:47
 * @Description 获取错误信息
 */
@ControllerAdvice
public class ExceptionHandle {

    @ExceptionHandler(value = Exception.class)
    @ResponseBody
    public ResultInfo handler(Exception e){
        LogUtils.LogInfo(ExceptionHandle.class,"错误信息:"+e.getMessage());
        return ResultUtils.error(100,e.getMessage());
    }
}
